package com.chapter10.inner_class.homework;

public class homework02 {
    public static void main(String[] args) {
        //匿名内部类打印:懒猪起床了
        CellPhone cellPhone = new CellPhone();
        cellPhone.alarmclock(new Bell() {
            @Override
            public void ring() {
                System.out.println("懒猪起床了");
            }
        });

        //第二个打印:小伙伴上课了
        cellPhone.alarmclock(new Bell() {
            @Override
            public void ring() {
                System.out.println("小伙伴上课了");
            }
        });
    }

}

interface Bell{
    void ring(); //抽象方法
}

class CellPhone{
    public void alarmclock(Bell bell){
        bell.ring();
    }
}





















